home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / src / maketype < prev    next >
Text File  |  1989-08-14  |  1KB  |  53 lines

  1. #!/bin/sh
  2. #
  3. #    Converts a template file to a typed file
  4. #
  5. #    Usage: maketype type template_file output_file
  6. #
  7. #    In what follows,
  8. #    <T> is the "type", e.g. DComplex
  9. #    <P> is the "precision", e.g. Double
  10. #    <A> is the "abbreviation"
  11. #
  12. #    Description       "Type"    "Precision" "Abbreviation"
  13. #    ___________       _____     __________  _____________
  14. #
  15. #    double prec.      Double     double          D
  16. #       float prec.       Float      float           F
  17. #       double complex    DComplex   double          C
  18. #    float complex     FComplex   float           B
  19. #
  20. if [ $# != 3 ]
  21. then
  22.     echo Usage: maketype type template_file output_file
  23.     exit 1
  24. fi
  25. #    Determine the precision and abbreviation
  26. case $1 in 
  27. DComplex)
  28.     precision="Double"
  29.     abbrev="C"
  30.     ;;
  31. FComplex)
  32.     precision="Float"
  33.     abbrev="B"
  34.     ;;
  35. Float)
  36.     precision="Float"
  37.     abbrev="F"
  38.     ;;
  39. Double)
  40.     precision="Double"
  41.     abbrev="D"
  42.     ;;
  43. # Default: select first character as abbrev:
  44. *)
  45.     precision=$1
  46.     abbrev=`echo $1 | sed  's/^\([A-Za-z]\).*/\1/'`
  47.     ;;
  48. esac
  49. rm -f $3
  50. sed "s/<T>/$1/g; s/<P>/$precision/g; s/<A>/$abbrev/g" $2 >$3
  51. # Readonly to discourage changes:
  52. chmod 444 $3
  53.